package br.com.guiav6.sisguia.utils;

import java.util.ArrayList;
import java.util.ResourceBundle;

public class PropertiesUtil {

	private ResourceBundle bundle;

	private static PropertiesUtil properties;
	
	private PropertiesUtil() {
	}

	public static PropertiesUtil getInstance() {
		if (properties == null){
			properties =  new PropertiesUtil();
		}
		return properties;
	}
	
	public PropertiesUtil setBundle(String bundle ){
		this.properties.bundle = ResourceBundle.getBundle(bundle);
		return this.properties;
	}

	public String getProperty(String key) {
		try {
			return bundle.getString(key);
		} catch (RuntimeException e) {
			return null;
		}
	}
	
	public String[] getKeys(){
		return bundle.keySet().toArray(new String[]{});
	}
	
	public String[] getValues(){
		ArrayList<String> values = new ArrayList<String>();
		
		String[] keys = this.getKeys();
		
		for(String k : keys){
			 values.add(bundle.getString(k));
		}
		
		return values.toArray(new String[]{});
	}
}